package InnerGameParts;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;

import OuterGameParts.UnitNotDeletedException;
import java.io.Serializable;

public class CannonBall implements Serializable{


	/**
	 * 
	 */
	private static final long serialVersionUID = -6345032715169614657L;
	private final  static int GRAPHICS_WIDTH  = 10; 
	private final static int GRAPHICS_HEIGHT = 10;
	private final static int MAX_CANNONBALL_LIFE = 50;

	private int mBallRadius = 2;
	
	//Top left handPositiong of the ships
	private int mDirection; 
	private int mXposition;
	private int mYposition;
	
	
	private int mSpeed;


	public CannonBall(final int direction, final  int xPosition, final  int yPosition){

		this.mDirection = direction;
		this.mXposition = xPosition;
		this.mYposition = yPosition;
		mSpeed = MAX_CANNONBALL_LIFE;

	}

	public boolean shouldDelete(){

		return --mSpeed <= 0;

	}

	/**
	 * 
	 */
	public void move() {
		
		mYposition -= (int) 10 * Math.cos(Math.toRadians(mDirection));				
		mXposition +=  (int) 10 * Math.sin(Math.toRadians(mDirection));

	}




	/*public BufferedImage renderBall(){

		BufferedImage ballImage = new BufferedImage(GRAPHICS_WIDTH,	GRAPHICS_HEIGHT,
				BufferedImage.TYPE_INT_ARGB);

		Graphics ballGraphics = ballImage.getGraphics();
		ballGraphics.setColor(Color.BLACK);
		ballGraphics.fillOval(GRAPHICS_WIDTH /2 - mBallRadius, GRAPHICS_WIDTH /2 - mBallRadius, mBallRadius * 2, mBallRadius * 2);

		return ballImage;

	}*/

	public int getX(){
		
		return mXposition;
		
	}
	
	public int getY(){
		
		
		return mYposition; 
		
	}
	
}
